<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Change ZK cluster ensemble membership and roles of ensemble peers</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="zookeeperconfig.remove.html">« ZookeeperConfig::remove</a></li>
      <li style="float: right;"><a href="class.zookeeperexception.html">ZookeeperException »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.zookeeperconfig.html">ZookeeperConfig</a></li>
    <li>Change ZK cluster ensemble membership and roles of ensemble peers</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="zookeeperconfig.set" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ZookeeperConfig::set</h1>
  <p class="verinfo">(PECL zookeeper &gt;= 0.6.0, ZooKeeper &gt;= 3.5.0)</p><p class="refpurpose"><span class="refname">ZookeeperConfig::set</span> &mdash; <span class="dc-title">Change ZK cluster ensemble membership and roles of ensemble peers</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-zookeeperconfig.set-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><strong>ZookeeperConfig::set</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$members</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$version</code><span class="initializer"> = -1</span></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$stat</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type void">void</span></span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-zookeeperconfig.set-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">members</code></dt>

    <dd>

     <p class="para">
      Comma separated list of new membership (e.g., contents of a membership configuration file) - for use only with a non-incremental reconfiguration.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">version</code></dt>

    <dd>

     <p class="para">
      The expected version of the node. The function will fail if the actual version of the node does not match the expected version. If -1 is used the version check will not take place.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">stat</code></dt>

    <dd>

     <p class="para">
      If not NULL, will hold the value of stat for the path on return.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-zookeeperconfig.set-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-zookeeperconfig.set-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   This method emits <span class="classname"><a href="class.zookeeperexception.html" class="classname">ZookeeperException</a></span> and it&#039;s derivatives when parameters count or types are wrong or fail to save value to node.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-zookeeperconfig.set-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="zookeeperconfig.set.example.basic">
   <p><strong>示例 #1 <span class="methodname"><strong>ZookeeperConfig::set()</strong></span> example</strong></p>
   <div class="example-contents"><p>
     Reconfig.
   </p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Zookeeper</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost:2181'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addAuth</span><span style="color: #007700">(</span><span style="color: #DD0000">'digest'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'timandes:timandes'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$zkConfig&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getConfig</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$zkConfig</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">set</span><span style="color: #007700">(</span><span style="color: #DD0000">"server.1=localhost:2888:3888:participant;0.0.0.0:2181"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-zookeeperconfig.set-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="zookeeperconfig.get.html" class="methodname" rel="rdfs-seeAlso">ZookeeperConfig::get()</a> - Gets the last committed configuration of the ZooKeeper cluster as it is known to the server to which the client is connected, synchronously</span></li>
   <li class="member"><span class="methodname"><a href="zookeeperconfig.add.html" class="methodname" rel="rdfs-seeAlso">ZookeeperConfig::add()</a> - Add servers to the ensemble</span></li>
   <li class="member"><span class="methodname"><a href="zookeeperconfig.remove.html" class="methodname" rel="rdfs-seeAlso">ZookeeperConfig::remove()</a> - Remove servers from the ensemble</span></li>
   <li class="member"><span class="classname"><a href="class.zookeeperexception.html" class="classname">ZookeeperException</a></span></li>
  </ul>
 </div>


</div></div></div></body></html>